import request from './request'

// 订单相关API接口

export interface Order {
  id: number
  order_no: string
  student_id: number
  course_id: number
  payment_method?: string
  registration_type: string
  should_pay_amount: number
  actual_pay_amount: number
  order_date?: string
  sales_employee_id?: number
  reception_employee_id?: number
  performance_source?: string
  status: string
  created_at?: string
  updated_at?: string
}

export interface OrderListResponse {
  items: Order[]
  total: number
  page: number
  size: number
}

/**
 * 获取订单列表
 */
export const getOrders = (params?: {
  page?: number
  size?: number
  order_no?: string
  student_id?: number
  course_id?: number
  status?: string
}): Promise<OrderListResponse> => {
  return request.get('/orders/', { params })
}

/**
 * 创建订单
 */
export const createOrder = (data: Partial<Order>): Promise<Order> => {
  return request.post('/orders/', data)
}

/**
 * 更新订单
 */
export const updateOrder = (id: number, data: Partial<Order>): Promise<Order> => {
  return request.put(`/orders/${id}`, data)
}

/**
 * 删除订单
 */
export const deleteOrder = (id: number): Promise<void> => {
  return request.delete(`/orders/${id}`)
}
